package com.example.marksixanim

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout

/**
 * @author robert
 * @date 2017/12/25
 */

class BallView : LinearLayout {

    private lateinit var mIvAnimal: ImageView
    private lateinit var mIvColor: ImageView
    private lateinit var mIvNumber1: ImageView
    private lateinit var mIvNumber2: ImageView
    private lateinit var content: View

    constructor(context: Context?) : super(context) {
        initView()
    }

    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
        initView()
    }

    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
        initView()
    }

    private fun initView() {
        content = LayoutInflater.from(context).inflate(R.layout.view_mark_six_ball, this, true)
        mIvAnimal = content.findViewById(R.id.iv_animal)
        mIvColor = content.findViewById(R.id.iv_color)
        mIvNumber1 = content.findViewById(R.id.iv_number1)
        mIvNumber2 = content.findViewById(R.id.iv_number2)
    }

    fun setAnimal(drawable: Int) {
        mIvAnimal.setImageResource(drawable)
    }

    fun setColor(drawable: Int) {
        mIvColor.setImageResource(drawable)
    }

    fun setNumber(drawable: IntArray) {
        mIvNumber1.setImageResource(drawable[0])
        mIvNumber2.setImageResource(drawable[1])
    }

}
